package com.ewzj.bigdata.mvp.ui.adapter

import android.view.View
import android.widget.ImageView

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.ewzj.bigdata.R
import com.ewzj.bigdata.app.extensions.loadImgwithloading
import com.ewzj.bigdata.app.utils.Apputils

/**
 * author:zhangjing
 * 作用:
 * return:
 */

class ImageAdapter(data: List<String>) : BaseQuickAdapter<String, BaseViewHolder>(R.layout.item_imageview, data) {

    var itemClicklistener: ItemClicklistener? = null

    override fun convert(baseViewHolder: BaseViewHolder, s: String) {
        baseViewHolder.getView<ImageView>(R.id.iv_pic).loadImgwithloading(Apputils.Utils.getImgUrl(s))
                baseViewHolder.getConvertView().setOnClickListener(View.OnClickListener {
            if (itemClicklistener != null) {
                itemClicklistener!!.onItemClick()
            }
        })
    }

    interface ItemClicklistener {
        fun onItemClick()
    }
}
